{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#tests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# -*- coding:utf-8 -*-"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys  \n",
    "import os\n",
    "from numpy import * \n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#from imp import reload"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[4 4]]\n"
     ]
    }
   ],
   "source": [
    "# 配置utf-8输出环境\n",
    "#reload(sys)\n",
    "#sys.setdefaultencoding('utf-8')\n",
    "\n",
    "base = mat([[1,3],[3,1]])\n",
    "print (base[0]+base[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[1, 3],\n",
       "        [3, 1]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "base"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEACAYAAABCl1qQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3Xd4VOXywPHv0FFEUCOioKgYpUoHO9jbhZ/lKnYBBQvitaAiSrMXLAh2UUS8imCJiA1MFPDSQZQiICogiIJSAgklmd8fs5AlJtkN2eTsJ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R7/5oFfzyjjjIfrKUC10P2KwDSgXa5z4uF3PZo4A/9dD4vlduDtvP59S/p6FnfLYlepEFXdBuwsFRKuEzAidH8McJpIiVeBiibOwKnqNxS8fqUT8KaaqUANEaldMtHliCLOwKnqalWdHbq/CViIVSIIF/j1jDLOwIWuUXroYcXQLffsmcB/16OMMy6ISB3gPODVfE4p0etZ3Mkir1Ihuf+j71YqBNhZKqQkRRMnwEWh7ogxIrKHG7wWq2j/HvHguFBXwKci0ijIQELN9+bYt8xwcXU9C4gT4uB6hrpM5gJ/AF+qar7XM8Df9WjihPj4XX8GuAvIzud4iV7P4k4WMSsVUsyiieFjoJ6qNgUmkJPR40k8XMtozAYOU9VjgeeAD4MKRESqAWOB/6jqxtyH83hKINczQpxxcT1VNUtVm2FVHtqISONcp8TF9YwizsB/10XkfOAPVZ1V0Gl5/KzYrmdxJ4tEKRUSMU5VXaeqW0MPX8H27og30VzvwKnqxp1dAao6HqgoIgeUdBwiUhH7AB6lqu/ncUpcXM9IccbL9QyLZz2QBpyd61A8/K7vkl+ccfK7fgLQUUR+wbrFTxWR3KVWS/R6FneySJRSIRHjzNVX3RHrO443KcDVoVk87YANqro66KByE5GDdvatikgb7P/huhKOQbDKAwtV9al8Tgv8ekYTZ5xczyQRqRG6XxU4HViU67TAf9ejiTMeftdVtY+q1lHVetjn0VeqemWu00r0ehbrtqpafKVCgoizl4h0BHaE4ry2pOMUkf9iM18OEJGVQH9sgA5VfREYj83gWQpsAbqUdIxRxnkxcKOI7AAygM4BfEE4AbgK+D7Ufw1wL3BoWJzxcD2jiTMermdtYITYZmnlgNGqOi7eftejjDPw3/X8BHk9vdyHc865iHwFt3POuYg8WTjnnIvIk4VzzrmIPFk455yLyJOFc865iDxZOOeci8iThXPOuYj+H4R2yrdgG7jZAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘图\n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(111)\n",
    "x1 = linspace(0,1,200)\n",
    "y1 = 3*x1\n",
    "x2 = linspace(0,3,200)\n",
    "y2 = x2/3 \n",
    "x3 = linspace(0,4,200)\n",
    "y3 = x3\n",
    "ax.plot(x1,y1,\"b\")\n",
    "plt.annotate(\"(1,3)\",xy = (1,3))\t\n",
    "ax.plot(x2,y2,\"b\")\n",
    "plt.annotate(\"(3,1)\",xy = (3,1))\t\n",
    "ax.plot(x3,y3,\"b\")\n",
    "plt.annotate(\"(4,4)\",xy = (4,4))\t\n",
    "plt.xlim(0, 4)\n",
    "plt.ylim(0, 4)\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "det(A): -812.0\n"
     ]
    }
   ],
   "source": [
    "# n阶方阵的行列式运算\n",
    "A = mat([[1,2,4,5,7,],[9,12,11,8,2,],[6,4,3,2,1,],[9,1,3,4,5],[0,2,3,4,1]])\n",
    "\n",
    "print (\"det(A):\",linalg.det(A))  # 方阵的行列式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[ 1,  2,  4,  5,  7],\n",
       "        [ 9, 12, 11,  8,  2],\n",
       "        [ 6,  4,  3,  2,  1],\n",
       "        [ 9,  1,  3,  4,  5],\n",
       "        [ 0,  2,  3,  4,  1]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "inv(A): [[-7.14285714e-02 -1.23152709e-02  5.29556650e-02  9.60591133e-02\n",
      "  -8.62068966e-03]\n",
      " [ 2.14285714e-01 -3.76847291e-01  1.22044335e+00 -4.60591133e-01\n",
      "   3.36206897e-01]\n",
      " [-2.14285714e-01  8.25123153e-01 -2.04802956e+00  5.64039409e-01\n",
      "  -9.22413793e-01]\n",
      " [ 1.66901077e-16 -4.13793103e-01  8.79310345e-01 -1.72413793e-01\n",
      "   8.10344828e-01]\n",
      " [ 2.14285714e-01 -6.65024631e-02  1.85960591e-01 -8.12807882e-02\n",
      "  -1.46551724e-01]]\n"
     ]
    }
   ],
   "source": [
    "invA = linalg.inv(A) # 矩阵的逆\n",
    "print( \"inv(A):\",invA)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 95 131  43  78  43]\n",
      " [131 414 153 168  91]\n",
      " [ 43 153  66  80  26]\n",
      " [ 78 168  80 132  32]\n",
      " [ 43  91  26  32  30]]\n"
     ]
    }
   ],
   "source": [
    "AT = A.T   #矩阵的对称\n",
    "print (A*AT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Matrix rank:  5\n"
     ]
    }
   ],
   "source": [
    "#矩阵的秩\n",
    "print ('Matrix rank: ',linalg.matrix_rank(A))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.0270936   1.77093596 -3.18472906  1.68965517  0.25369458]\n"
     ]
    }
   ],
   "source": [
    "#可逆矩阵求解\n",
    "b = [1,0,1,0,1] \n",
    "S = linalg.solve(A,transpose(b))\n",
    "print (S)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import loadbigdata as loadbigdata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b'cnumpy.core.multiarray'\n",
      "b'_reconstruct'\n",
      "b'p1'\n",
      "b'(cnumpy.matrixlib.defmatrix'\n",
      "b'matrix'\n",
      "b'p2'\n",
      "b'(I0'\n",
      "b\"tS'b'\"\n",
      "b'tRp3'\n",
      "b'(I1'\n"
     ]
    }
   ],
   "source": [
    "path = \"testdata/recordmat.dat\" #数据文件所在路径\n",
    "# 读取10行,\n",
    "for line in loadbigdata.readfilelines(path,nmax=10):\n",
    "    #print(line)\n",
    "    print (line.strip())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import loaddata as loaddata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "root = \"testdata\" #数据文件所在路径\n",
    "pathlist = os.listdir(root) # 获取路径下所有数据文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['01.txt', '02.txt', 'recordmat.dat']"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pathlist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(4103, 9)\n",
      "(2737, 9)\n",
      "(27, 1)\n"
     ]
    }
   ],
   "source": [
    "for path in pathlist:\n",
    "    recordmat = loaddata.file2matrix(root+\"/\"+path,b\"\\t\") # 文件到矩阵的转换\n",
    "    print (shape(recordmat)) # 输出解析后矩阵的行、列数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0. 0. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 0.]\n",
      " [0. 0. 0. 0. 0.]]\n",
      "[[1. 1. 1. 1. 1.]\n",
      " [1. 1. 1. 1. 1.]\n",
      " [1. 1. 1. 1. 1.]]\n",
      "[[0.83302641 0.86923904 0.06423151 0.85636327]\n",
      " [0.15646801 0.32102271 0.41122535 0.4150337 ]\n",
      " [0.15789796 0.5642994  0.91168985 0.94785467]]\n",
      "[[1. 0. 0.]\n",
      " [0. 1. 0.]\n",
      " [0. 0. 1.]]\n"
     ]
    }
   ],
   "source": [
    "myZero = np.zeros([3,5]) #3*5的全零矩阵 \n",
    "print (myZero)\n",
    "\n",
    "\n",
    "myOnes = np.ones([3,5]) #3*5的全零矩阵 \n",
    "print (myOnes)\n",
    "\n",
    "# 随机矩阵:3行4列的0~1之间的随机数矩阵\n",
    "myRand = np.random.rand(3,4)\n",
    "print (myRand)\n",
    "\n",
    "# 单位阵\n",
    "myEye = np.eye(3) # 3*3的单位阵\n",
    "print (myEye)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 测试数据集\n",
    "dataSet = [[-0.017612,14.053064],[-1.395634\t,4.662541],[-0.752157\t,6.538620],[-1.322371\t,7.152853],\n",
    "[0.423363\t,11.054677],[0.406704\t,7.067335],[0.667394\t,12.741452],[-2.460150\t,6.866805],\n",
    "[0.569411\t,9.548755],[-0.026632\t,10.427743],[0.850433\t,6.920334],[1.347183\t,13.175500],\n",
    "[1.176813\t,3.167020],[-1.781871\t,9.097953]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.017612, -1.395634, -0.752157, -1.322371,  0.423363,  0.406704,\n",
       "         0.667394, -2.46015 ,  0.569411, -0.026632,  0.850433,  1.347183,\n",
       "         1.176813, -1.781871]])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将数据集转换为numpy矩阵，并转置\n",
    "dataMat = mat(dataSet).T\n",
    "dataMat[0].tolist()\n",
    "array(dataMat[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0xb3f9630>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAD8CAYAAACINTRsAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAEGRJREFUeJzt3X+IbOV9x/HP53oxdiStmrtGk5vd0SL2hxQiSzAKaYixXFLRlKZFmdBrY1mk9AeFkhgWEihc2jSF/iBtw9RaLR1upJfa2BBbrVb8R233Gq9Xo4nG3t3caL1rLJZ0Icb67R/nbO7uurNzZs6cOWeefb9AzswzZ+Z8eXbvx2ee85yzjggBANKwp+4CAADjQ6gDQEIIdQBICKEOAAkh1AEgIYQ6ACSEUAeAhBDqAJAQQh0AErJ3kgfbt29ftNvtSR4SAKbe0aNHX4mImSL7TjTU2+22lpaWJnlIAJh6tpeL7sv0CwAkhFAHgIQQ6gCQEEIdABJCqANAQgh1YFr0elK7Le3Zk217vborQgMNDHXbt9s+ZfupbV77Xdthe1815QGQlAX4woK0vCxFZNuFBYIdb1FkpH6HpANbG22/R9I1klbGXBOArRYXpbW1zW1ra1k7sMHAUI+IhyW9us1Lfyzpk5L4I6dA1Vb6jJ36tWPXGmlO3fZ1kr4TEccK7Ltge8n20urq6iiHAzA7O1w7dq2hQ912S9KipM8U2T8iuhExHxHzMzOFbl0AYKtDh6RWa3Nbq5W1AxuMMlL/cUkXSTpm+4Sk/ZIet33BOAsDsEGnI3W70tycZGfbbjdrBzYY+oZeEXFc0vnrz/Ngn4+IV8ZYF4CtOh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Z5atr7b+s/2y7Qsj4qX8a/ipPp+x3n8v2H5I0nuVzS2PW5G+WN/npO29kn5MFXyl72NgfRHx3Q1P/0rZuaimqPR3rayI+J8Nj79q+y9s74uIHe9Z07jpF9sHJH1K0nURsdZnn7Ntv339sbITmNueQZ50bZL+Q9Ilti+yfaayk1eVrpAYRl19N4Q6++8eSQfzxwclveWbhe1zbb8tf7xP0lWSvl5RPUX6YmPNH5P0YL+BUB31bZmjvk7SMxOqrYh7JP1KvgrmCkmvrU+/NYHtC9bPj9h+n7K8/u7O71IjV788r2ye64n8v/Uz+++S9NX88cXKzrQfk/S0sq/2jagtTp9V/6ay0dtEasuP+wvKRh/fl/SypH9pSt8Vra/m/nuHpAckPZdvz8vb5yXdlj++UtLxvP+OS7q54pre0heSfk/ZwEKSzpL09/nv5r9LunhS/VWwvt/Pf8+OSfo3ST8xwdoOS3pJ0g/y37ubJd0i6Zb8dUv687z249phxVhN9f3Ghr57VNKVRT6XK0oBICGNm34BAIyOUAeAhBDqAJAQQh0AEkKoA0BCCHUASAihDgAJIdQBICH/D55B1VoTNbaxAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制数据集散点图\n",
    "plt.scatter(array(dataMat[0]),array(dataMat[1]),c='red',marker='o')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3Xd4VGXexvHvQw2hhxB6CD1AiAihCBYU1oKAIrqra2/o7rt9lYCg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YIN0HWWqfFfXfAAABKElEQVTy8x+d93LgwxPsTPg11zHHWadQfXw2ECwHrvOcvTEaKPjhEJuTjDGdf3jvwxgzkuqu23/yr6r3Og3wHLDRWvvXEyzm2+3lz3eBa/mOcTbVx5q+9/z54cyDrsDKY941zqJ6b262H3JNpfpf2TIgF3jv2FxUn62wwfMnLVByObS9OgCrgU2ejxGe+xOAZz23xwApnu2VAtzswzw/+fmB+6jecQAIA97wPP++Bnr7ehvVMNdDnufSBuAjINZPuV4B9gAVnufXzcDtwO2exw3wT0/uFE5y5pefc/3mqO21Fhjjh0xnUn34xHVUb0305/bSlaIiIiEiYA+5iIhI7ajQRURChApdRCREqNBFREKECl1EJESo0EVEQoQKXUQkRKjQRURCxP8DNZd7AbgRXvgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制直线图形\n",
    "# 产生直线数据集\n",
    "X = np.linspace(-2,2,100)\n",
    "# 建立线性方程\n",
    "Y = 2.8*X+9\n",
    "# 绘制直线图\n",
    "plt.plot(X,Y)\n",
    "# 显示绘制后的结果\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "featuremat = mat([[88.5,96.8,104.1,111.3,117.7,124.0,130.0,135.4,140.2,145.3,151.9,159.5,165.9,169.8,171.6,172.3,172.7],\n",
    "[12.54,14.65,16.64,18.98,21.26,24.06,27.33,30.46,33.74,37.69,42.49,48.08,53.37,57.08,59.35,60.68,61.40]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9816014257595662\n"
     ]
    }
   ],
   "source": [
    "# 计算均值\n",
    "mv1 = mean(featuremat[0]) # 第一列的均值\n",
    "mv2 = mean(featuremat[1]) # 第二列的均值 \n",
    "# 计算两列标准差\n",
    "dv1 = std(featuremat[0])\n",
    "dv2 = std(featuremat[1])\n",
    "\n",
    "corref = mean(multiply(featuremat[0]-mv1,featuremat[1]-mv2))/(dv1*dv2)\n",
    "print (corref)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1.         0.98160143]\n",
      " [0.98160143 1.        ]]\n",
      "[[ 0.0345709  -0.05476345]\n",
      " [-0.05476345  0.09003275]]\n",
      "[[0.92966634]]\n"
     ]
    }
   ],
   "source": [
    "print (corrcoef(featuremat))\n",
    "# numpy.linalg.inv()函数计算给定矩阵的逆矩阵。\n",
    "covinv = linalg.inv(cov(featuremat))\n",
    "print (covinv)\n",
    "tp = featuremat.T[0]-featuremat.T[1]\n",
    "distma = sqrt(dot(dot(tp,covinv),tp.T))\n",
    "print (distma )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[5.19615242]]\n",
      "[[-3.06186218 -1.83711731 -0.61237244]\n",
      " [ 0.61237244  1.83711731  3.06186218]]\n",
      "[[6.36396103]]\n"
     ]
    }
   ],
   "source": [
    "vectormat = mat([[1,2,3],[4,5,6]])\n",
    "v12 = vectormat[0]-vectormat[1]\n",
    "print (sqrt(v12*v12.T))\n",
    "#norm\n",
    "varmat = std(vectormat.T,axis=0)\n",
    "#mean :Compute the arithmetic mean along the specified axis\n",
    "normvmat = (vectormat-mean(vectormat))/varmat.T\n",
    "#norm\n",
    "print( normvmat)\n",
    "normv12 = normvmat[0]-normvmat[1]\n",
    "print (sqrt(normv12*normv12.T))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[1, 2, 3],\n",
       "        [4, 5, 6]])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vectormat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[1, 4],\n",
       "        [2, 5],\n",
       "        [3, 6]])"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#转置矩阵\n",
    "vectormat.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ True False False  True]\n",
      " [ True False  True  True]\n",
      " [False  True  True  True]\n",
      " [False False  True False]]\n"
     ]
    }
   ],
   "source": [
    "myRand = np.random.rand(4,4)>0.5\n",
    "print( myRand)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bool_2_num(bool):\n",
    "    if bool:\n",
    "        return 1\n",
    "    else:\n",
    "        return 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "res=[]\n",
    "for x in myRand:\n",
    "    temp=[bool_2_num(y) for y in x]\n",
    "    res.append(temp)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "myR1=np.array(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 0, 0, 1],\n",
       "       [1, 0, 1, 1],\n",
       "       [0, 1, 1, 1],\n",
       "       [0, 0, 1, 0]])"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myR1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "featurevector,eigenvalue = np.linalg.eig(myR1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2.54371986e-01, -7.98840359e-01,  5.77350269e-01,\n",
       "        -3.78553589e-01],\n",
       "       [ 5.71568665e-01, -4.43322953e-01,  5.77350269e-01,\n",
       "         3.03576408e-01],\n",
       "       [ 7.12734467e-01,  1.97297275e-01,  2.46879409e-16,\n",
       "        -5.47025786e-01],\n",
       "       [ 3.17196679e-01,  3.55517405e-01, -5.77350269e-01,\n",
       "         6.82129998e-01]])"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eigenvalue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2.24697960e+00,  5.54958132e-01,  1.84383817e-16, -8.01937736e-01])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "featurevector"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
